package org.example;

import com.fj.redisson.config.RedissonProperties;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;

/**
 * @author fj
 * @date 2023/12/26 15:57
 */
@SpringBootApplication
public class App implements ApplicationRunner {

    @Primary
    @Bean
    public RedissonProperties redissonProperties(){
        RedissonProperties redissonProperties = new RedissonProperties();
        redissonProperties.setHost("8.218.94.20");
        redissonProperties.setPort(16379);
        redissonProperties.setDb(1);
        redissonProperties.setPassword("e0496f8850199016");
        return redissonProperties;
    }

    public static void main(String[] args) {
        SpringApplication.run(App.class);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
//        RBucket<String> key1 = redissonClient.getBucket("key1");
//        key1.set("bbb");
//        key1 = redisson.getBucket("key1");
//        System.out.println(key1.get());
//        redissonClient.shutdown();
//        for (int i = 0;i<20;i++){
//            int finalI = i;
//            new Thread(() -> {
//                setVal(finalI +"",finalI+"");
//                try {
//                    Thread.sleep(2000);
//                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);
//                }
//                getVal(finalI+"");
//            }).start();
//        }
        System.out.println("---finish---");
    }
}
